<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@page import="com.tqz.dao.NewsSerch_incountry"%>


<%@page import="com.tqz.dao.NewsSerch"%>
<%@page import="com.tqz.dao.NewsSerch_army"%>
<%@page import="com.tqz.dao.NewsSerch_entertainment"%>
<%@page import="com.tqz.dao.NewsSerch_incountry"%>
<%@page import="com.tqz.dao.NewsSerch_outcountry"%>
<%@page import="com.tqz.dao.NewsSerch_society"%>
<%@page import="com.tqz.dao.NewsSerch_sports"%>
<%@page import="com.tqz.dao.NewsSerch_tech"%>

<link rel="stylesheet" type="text/css" href="css/newshome.css">

<%@page import="java.util.List"%>
<%@page import="com.tqz.model.Article"%>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/addnews.css">
<title>新增新闻</title>
</head>
<body>
	<div id="head">
		<div class="logo">
			<img src="picture/logo.png">
		</div>
		<div class="title">
			<span>知天下</span>
		</div>
	</div>
	<div id="nav">
		<div class="navblock">
			<ul>
				<li><a href="javascript:viod(0)" class="detail">删除新闻</a></li>
			</ul>
		</div>
	</div>
	<div id="mainbody">
		<%
			int type=Integer.valueOf(request.getParameter("type"));
			request.setAttribute("type",type);
			String types="";
			switch(type){
				case 0:{
					types="NewsSerch";
					request.setAttribute("types",types);
					NewsSerch newsSerch = new NewsSerch();
					List<Article> list = newsSerch.getAllArticles();
					request.setAttribute("result", list);
					request.setAttribute("className", "NewsSerch_incountry");
					break;
				}
				case 1:{
					types="NewsSerch_incountry";
					request.setAttribute("types",types);
					NewsSerch_incountry newsSerch = new NewsSerch_incountry();
					List<Article> list = newsSerch.getAllArticles();
					request.setAttribute("result", list);
					request.setAttribute("className", "NewsSerch_incountry");
					break;
				}
				case 2:{
					types="NewsSerch_outcountry";
					request.setAttribute("types",types);
					NewsSerch_outcountry newsSerch = new NewsSerch_outcountry();
					List<Article> list = newsSerch.getAllArticles();
					request.setAttribute("result", list);
					request.setAttribute("className", "NewsSerch_incountry");
					break;
				}
				case 3:{
					types="NewsSerch_society";
					request.setAttribute("types",types);
					NewsSerch_society newsSerch = new NewsSerch_society();
					List<Article> list = newsSerch.getAllArticles();
					request.setAttribute("result", list);
					request.setAttribute("className", "NewsSerch_incountry");
					break;
				}
				case 4:{
					types="NewsSerch_army";
					request.setAttribute("types",types);
					NewsSerch_army newsSerch = new NewsSerch_army();
					List<Article> list = newsSerch.getAllArticles();
					request.setAttribute("result", list);
					request.setAttribute("className", "NewsSerch_incountry");
					break;
				}
				case 5:{
					types="NewsSerch_tech";
					request.setAttribute("types",types);
					NewsSerch_tech newsSerch = new NewsSerch_tech();
					List<Article> list = newsSerch.getAllArticles();
					request.setAttribute("result", list);
					request.setAttribute("className", "NewsSerch_incountry");
					break;
				}
				case 6:{
					types="NewsSerch_sports";
					request.setAttribute("types",types);
					NewsSerch_sports newsSerch = new NewsSerch_sports();
					List<Article> list = newsSerch.getAllArticles();
					request.setAttribute("result", list);
					request.setAttribute("className", "NewsSerch_incountry");
					break;
				}
				case 7:{
					types="NewsSerch_entertainment";
					request.setAttribute("types",types);
					NewsSerch_entertainment newsSerch = new NewsSerch_entertainment();
					List<Article> list = newsSerch.getAllArticles();
					request.setAttribute("result", list);
					request.setAttribute("className", "NewsSerch_incountry");
					break;
				}
				default:{
					NewsSerch newsSerch = new NewsSerch();
					List<Article> list = newsSerch.getAllArticles();
					request.setAttribute("result", list);
					request.setAttribute("className", "NewsSerch_incountry");
					break;
				}
			}
			
			
			
		%>
		
		<c:forEach items="${ result }" var="article">
			<!-- 类型自动强转 -->
			<div class="infoframe">
				<div class="infobody">
					<div class="form">
						<form action="<%=request.getContextPath()%>/DeleteNewsServlet" method="post">
					<h2>
						<a href="<%=request.getContextPath()%>/update.jsp?id=${ article.getId() }&className=${types}&type=${type}">
						<c:out value="${ article.getTitle() }"></c:out>
						</a>
						<div style="text-align: right">
							<input id="deletebutton"  type="submit" value="删除" style="text-align: right;">
						</div>
					</h2>
							<input name="type" value="<%=request.getParameter("type") %>" type="hidden">
							<input type="hidden" name="title" value="${ article.getTitle() }" required="true">
							
						</form>
				</div>
			</div>
		</c:forEach>
	</div>
	
	
</body>
</html>